# from rapidocr_onnxruntime import RapidOCR

# engine = RapidOCR(config_path="config`2`2`21.yaml")

# img_path = 'C:/Users/jhuatin/Downloads/Untitled.png'
# result, elapse = engine(img_path, use_det=False, use_cls=False, use_rec=True)
# for i in range(len(result)):
#     print("识别值:"+result[i][1], "精度:"+result[i][2])
#print(elapse)

from paddleocr import PaddleOCR, draw_ocr

# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=True, show_log=False, lang="ch")  # need to run only once to download and load model into memory
img_path = 'http://api.zhuhui.store/uploads/65b4fd8b247.png'
list = []
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        #print(line)
        list.append(line)
print(list)

# 显示结果
# 如果本地没有simfang.ttf，可以在doc/fonts目录下下载
# from PIL import Image
# result = result[0]
# image = Image.open(img_path).convert('RGB')
# boxes = [line[0] for line in result]
# txts = [line[1][0] for line in result]
# scores = [line[1][1] for line in result]
# im_show = draw_ocr(image, boxes, txts, scores, font_path='doc/fonts/simfang.ttf')
# im_show = Image.fromarray(im_show)
# im_show.save('result.jpg')


# from paddlespeech.cli.asr.infer import ASRExecutor
# asr = ASRExecutor()
# result = asr(audio_file="C:/Users/jhuatin/Downloads/1553422829215244.mp3")
# print(result)